package controlLayer;
import modelLayer.DVDContainer;
import modelLayer.DVD;
import modelLayer.Copy;

/**
 * DVDCtr is a class that connects the DVD interface with the DVD domaine class.
 * 
 * @author group 6 - Stefan Patatu, Stan Cosmin Madalin, Monika Vysniauskaite, Larowski Michal, Njogu Alex, Cristian Moldovan
 */
public class DVDCtr {
    private DVDContainer dvdContainer;
    
    /**
     * Get the DVDContainer instance.
     */
    public DVDCtr() {
        dvdContainer = DVDContainer.getInstance();
    }

     /**
     * Create a DVD object.
     * @param title The title of a dvd.
     * @param barcode The barcode of a dvd.
     * @param artist The artist of the dvd.
     * @param publicationDate The publication date of a dvd.
     */
    public void createDVD(String title, long barcode, String artist, String publicationDate) {
        DVD d = new DVD(title, barcode, artist, publicationDate);
        dvdContainer.addDVD(d);
    }
    
    /**
    * Update a DVD object which has a certain barcode.
    * @param barcode The barcode of the DVD object to be updated.
    * @param title The new title of a DVD object.
    * @param artist The new artist of a DVD object.
    * @param publicationDate The new publication date of a DVD object
    */
    public void updateDVD(long barcode, String title, String artist, String publicationDate) {
        dvdContainer.updateDVD(barcode, title, artist, publicationDate);
    }
    
    public DVD findDVD(long barcode) {
        return dvdContainer.findDVD(barcode);
    }
    
    public Copy findDVDCopy(int serialNumber) {
        return dvdContainer.findCopy(serialNumber);
    }
  
    /**
    * Delete a DVD object which by a given barcode.
    * @param barcode The barcode of the DVD object to be deleted.
    */
    public void deleteDVD(long barcode) {
        dvdContainer.deleteDVD(barcode);
    }
    
    /**
     * Add a copy of a dvd to a dvd
     * @param barcode The barcode of a DVD object.
     * @param serialNumber The serialNumber of a copy of a dvd
     * @param purchase price The purchase price of a copy of a dvd
     * @param purchaseDate The purchase date of a copy of a dvd.
     */
    public void addCopy(long barcode, int serialNumber, int purchasePrice, String purchaseDate){
        dvdContainer.getDVD(barcode).addCopy(serialNumber, purchasePrice, purchaseDate);
    }
   
}